<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="edu.upeu.lp1.common.Conexion" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
<%
String UserId=request.getParameter("UserId");
String Name="";
String Login="";
String Password="";
String ForcePasswordChange="";
String Email="";
String Privilege="";
String ActiveAccount="";
String DateCreate="";
        Conexion conn = new Conexion();
        try {           
            String qry="select * from User where UserId=?";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1,UserId);
            ResultSet rs= ps.executeQuery();
            if(rs.next())
                Name=rs.getString("Name");
                Login=rs.getString("Login");
                Password=rs.getString("Password");
                ForcePasswordChange=rs.getString("ForcePasswordChange");
                Email=rs.getString("Email");
                Privilege = rs.getString("Privilege");
                ActiveAccount=rs.getString("ActiveAccount");
                DateCreate=rs.getString("DateCreate");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }
%>               
    <form action="CursoSave.jsp" name="fm">
            <br> <input type="hidden" name="go" value="Edit">
            <br>CursoId <input type="text" name="UserId" value="<%=UserId%>" readonly="true">
            <br>Nombre: <input type="text" name="name" value="<%=Name%>">
            <br>Login: <input type="text" name="name" value="<%=Login%>">
            <br>Password: <input type="text" name="name" value="<%=Password%>">
            <br>ForcePasswordChange: <input type="text" name="name" value="<%=ForcePasswordChange%>">
            <br>Email: <input type="text" name="name" value="<%=Email%>">
            <br>Privilege: <input type="text" name="name" value="<%=Privilege%>">
            <br>ActiveAccount: <input type="text" name="name" value="<%=ActiveAccount%>">
            <br>DateCreate: <input type="text" name="name" value="<%=DateCreate%>">
            
            <br><input type="submit" value="Edit">
            <input type="button" value="Eliminar" onclick="del()">
        </form>
    </body>
</html>
<script>
    function del(){
        document.fm.go.value="Delete";
        if(confirm("Está seguro eliminar?")) 
            document.fm.submit();
    }
</script>